﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace System
{
    public static class Check
    {
        public static class Argument
        {
            public static void IsNotNull<T>(T arg, string name)
            {
                if (arg == null) {
                    throw new ArgumentException(String.Format("{0} ({1}) is null", name, typeof(T).Name));
                }
            }

            public static void IsNotNullOrEmpty(string arg, string name)
            {
                if (String.IsNullOrEmpty(arg) == true) {
                    throw new ArgumentException(String.Format("{0} ({1}) is null or empty", name, typeof(string).Name));
                }
            }

            public static void IsNotNullOrWhiteSpace(string arg, string name)
            {
                if (String.IsNullOrWhiteSpace(arg) == true) {
                    throw new ArgumentException(String.Format("{0} ({1}) is null or whitespaced", name, typeof(string).Name));
                }
            }

            public static void IsAcceptable<T>(T arg, string name, Func<T, bool> predicate)
            {
                if (predicate(arg) == false) {
                    throw new ArgumentException(String.Format("Argument {0} ({1}) fail acceptable test", name, typeof(T).Name));
                }
            }
        }
    }
}
